import React from 'react';
import {
    Table,
    Row,
    Col,
    Form,
    Input,
    Icon,
    InputNumber,
    Radio,
    DatePicker,
    Select,
    Upload,
    Button,
    Switch,
    Modal,
    Popconfirm,
    Tabs,
    message
} from 'antd';
import BizParams from '../../components/commons/BizParams'
import SingleDragger from '../../components/commons/SingleDragger'
import CurrencySelect from '../../components/commons/CurrencySelect'
import OperatorConstant from "../../utils/OperatorConstant";

const R = require('ramda');
import moment from 'moment'

const TabPane = Tabs.TabPane;
const FormItem = Form.Item;
const dateFormat = 'YYYY-MM-DD';


export default Form.create({wrappedComponentRef: true})(class Statement extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            open: false,
            disabled: true,
            type: "",
        }
    }

    handleCancel = () => {
        this.props.form.resetFields();
    }


    render() {
        const {getFieldDecorator} = this.props.form;
        const formItemLayout = {labelCol: {xs: {span: 8}, sm: {span: 8}}, wrapperCol: {xs: {span: 15}, sm: {span: 14}}};
        let dataSource = R.isNil(this.props.dataSource) || R.isNil(this.props.dataSource.statement) ? {} : this.props.dataSource.statement;

        let disable = true;
        let disableApproval = this.state.disabled || this.state.type == OperatorConstant.view;

        return (
            <div>
                <Row>
                    <Col span={12}>

                        <FormItem {...formItemLayout} label="结算单号" hasFeedback>
                            {getFieldDecorator('stateno', {
                                initialValue: dataSource.stateno
                            })(
                                <Input style={{width: '100%'}} disabled={disable}/>
                            )}
                        </FormItem>
                    </Col>


                    <Col span={12}>

                        <FormItem {...formItemLayout} label="结算对象" hasFeedback>
                            {getFieldDecorator('stObj', {
                                initialValue: {"0": "工厂供应商", "1": "物流供应商", "2": "海关"}[dataSource.stObj] || ""
                            })(
                                <Input style={{width: '100%'}} disabled={disable}/>
                            )}
                        </FormItem>
                    </Col>

                    <Col span={12}>
                        <FormItem {...formItemLayout} label="收款单位名称" hasFeedback>
                            {getFieldDecorator('companyName', {
                                initialValue: dataSource.companyName
                            })(
                                <Input disabled={disable}/>
                            )}
                        </FormItem>
                    </Col>

                    <Col span={12}>
                        <FormItem {...formItemLayout} label="结算日期" hasFeedback>
                            {getFieldDecorator('createtime', {
                                rules: [{
                                    // required: true, message: '请输入费用申报时间',
                                }],
                                initialValue: (dataSource.createtime == '' || dataSource.createtime == null) ? '' : moment(dataSource.createtime, dateFormat)

                            })(
                                <DatePicker
                                    showTime={{format: 'YYYY-MM-DD'}}
                                    format="YYYY-MM-DD"
                                    placeholder="请选择时间"
                                    style={{width: '100%'}} disabled={disable}/>
                            )}
                        </FormItem>
                    </Col>

                    <Col span={12}>
                        <FormItem {...formItemLayout} label="实际支付" hasFeedback>
                            {getFieldDecorator('transferamount', {
                                initialValue: dataSource.transferamount
                            })(
                                <InputNumber style={{width: '100%'}} disabled={disable}/>
                            )}
                        </FormItem>
                    </Col>


                    {/*<Col span={12}>*/}
                    {/*    <FormItem {...formItemLayout} label="本次结余" hasFeedback>*/}
                    {/*        {getFieldDecorator('unpayamount', {*/}
                    {/*            initialValue: dataSource.unpayamount*/}
                    {/*        })(*/}
                    {/*            <InputNumber style={{width: '100%'}} disabled={disable}/>*/}
                    {/*        )}*/}
                    {/*    </FormItem>*/}
                    {/*</Col>*/}


                    <Col span={12}>
                        <FormItem {...formItemLayout} label="收款人" hasFeedback>
                            {getFieldDecorator('accname', {

                                initialValue: dataSource.accname
                            })(
                                <InputNumber style={{width: '100%'}} disabled={disable}/>
                            )}
                        </FormItem>
                    </Col>
                    <Col span={12}>
                        <FormItem {...formItemLayout} label="银行名称" hasFeedback>
                            {getFieldDecorator('accopenbank', {
                                initialValue: dataSource.accopenbank
                            })(
                                <Input disabled={disable}/>
                            )}
                        </FormItem>
                    </Col>
                    <Col span={12}>
                        <FormItem {...formItemLayout} label="银行账号" hasFeedback>
                            {getFieldDecorator('accno', {
                                initialValue: dataSource.accno
                            })(
                                <Input disabled={disable}/>
                            )}
                        </FormItem>
                    </Col>





                    {/*<Col span={12}>*/}
                    {/*    <FormItem*/}
                    {/*        {...formItemLayout}*/}
                    {/*        label="结算方式"*/}
                    {/*        hasFeedback*/}
                    {/*    >*/}
                    {/*        {getFieldDecorator('settletype', {*/}
                    {/*            rules: [{*/}
                    {/*                required: true, message: '请选择结算方式！',*/}
                    {/*            }],*/}
                    {/*            initialValue: dataSource.settletype*/}
                    {/*        })(*/}
                    {/*            <Select disabled={disable} style={{width: '100%'}}>*/}
                    {/*                <Option value="1">无订单结算</Option>*/}
                    {/*                <Option value="2">有订单结算</Option>*/}
                    {/*            </Select>*/}
                    {/*        )}*/}
                    {/*    </FormItem>*/}
                    {/*</Col>*/}

                    <Col span={12}>
                        <FormItem {...formItemLayout} label="进口备注" hasFeedback>
                            {getFieldDecorator('memo', {
                                initialValue: dataSource.memo
                            })(
                                <Input.TextArea disabled={disable} maxLength="200" autosize={true}/>
                            )}
                        </FormItem>
                    </Col>

                </Row>
            </div>

        );

    }
})


